package cn.wubo.vrr.help.service.impl;

import cn.wubo.vrr.help.entity.Work;
import cn.wubo.vrr.help.repository.WorkRepo;
import cn.wubo.vrr.help.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkServiceImpl implements WorkService {
    @Autowired
    WorkRepo workRepo;

    @Override
    public List<Work> saveOrUpdateAll(List<Work> list) {
        if(list.size() > 0){
            Work query = new Work();
            query.setEMPLID(list.get(0).getEMPLID());
            workRepo.deleteAll(workRepo.findAll(Example.of(query)));
            list = workRepo.saveAll(list);
        }
        return list;
    }
}
